package com.example.demo2.service;

import com.example.demo2.util.RabbitMqUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class OrderService {
    @Autowired
    RabbitTemplate rabbitTemplate;
    public void sendOrder(String name,String thing,int num){
        String uuid= UUID.randomUUID().toString();
        System.out.println("订单生成成功"+uuid);
        String routingKey="";
        String message="hello springboot";
        //通过MQ来实现消息的分发
        rabbitTemplate.convertAndSend(RabbitMqUtils.ORDER_EXCHANGE,routingKey,message+uuid);
    }
}
